package com.example.renyang.happysell.MyUntil;

import android.util.Log;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.InputStream;
import java.util.Arrays;

/**
 * Created by john on 16/4/22.
 */
public class ImageViewUtil {
    public static byte[] decode(String url,int bufferMax,int buffer){
        byte[] bs = new byte[bufferMax];
        int total=0;
        try{
        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet(url);
        HttpResponse resp = client.execute(request);
            HttpEntity entity=resp.getEntity();
        InputStream in=resp.getEntity().getContent();
        int m=0;
        while ((m=in.read(bs,total,buffer))>0){
            total+=m;
        }

    }catch (Exception e){
        Log.i("john","error.......");
    }
        return Arrays.copyOfRange(bs, 0, total);
    }
}
